﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading;

namespace Helpers.Language
{
    public static class LangRes
    {
        private static ResourceManager Resources { get; set; }
        private static CultureInfo Ci { get; set; }

        public static void SetLanguage(string language)
        {
            Resources = new ResourceManager("Helpers.Language.Language", Assembly.GetAssembly(typeof(LangRes)));
            language = language ?? Properties.Settings.Default.DefaultLanguage;
            Ci = new CultureInfo(language);
            Thread.CurrentThread.CurrentCulture = Ci;
            Thread.CurrentThread.CurrentUICulture = Ci;
        }

        public static string Get(string name)
        {
            return Resources.GetString(name, Ci);
        }
    }
}
